/**
 * Created by Administrator on 2022/8/19.
 */
class Person {
    public String name;
    String gender;
    private int age;

    public Person(String name, String gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    public void print() {
        System.out.println(this.name);
        System.out.println(this.gender);
        System.out.println(this.age);
    }

    public String toString() {
        return "[" + name + "," + gender + "," + age + "]";
    }

    public static void main(String[] args) {
        Person person = new Person("阿紫","女",18);
        //这种方法打印一旦打印项多了非常麻烦
        //person.print();

        //可以采用这种方法,重新toString
        System.out.println(person);

    }
}
